/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.posplus.losspreventiondataimporter.service;

import com.posplus.lossprevention.APDAOFactory;
import com.posplus.lossprevention.dao.DepartmentsDAO;
import com.posplus.lossprevention.mapping.Departments;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author scottw
 */
public class DepartmentsService {

    private DepartmentsDAO departmentsDAO;
    
    public DepartmentsService(APDAOFactory lpFactory) {
        this.departmentsDAO = lpFactory.getDepartmentsDAO();
    }
    
    public DepartmentsService(DepartmentsDAO departmentsDAO){
        this.departmentsDAO = departmentsDAO;
    }
    
    public List<Departments> getAll(){
        return departmentsDAO.findAll();
    }

    public void bulkInsert(List<Departments> mappedDepartments) {
        departmentsDAO.bulkInsert(mappedDepartments);
    }

    public void save(Departments department) {
        departmentsDAO.makePersistent(department);
    }

    public void saveAll(List<Departments> mappedDepartments) {
	Iterator<Departments> iter = mappedDepartments.iterator();
	while (iter.hasNext()) {
	    departmentsDAO.save(iter.next());
	    
	}
    }
}
